#include <iostream>
#include <math.h>

using namespace std;

int main(int argc, char **argv)
{
	int t;
	cin>>t;
	for (int i = 0; i < t; i++) {
		long long j;
		cin>>j;
		
		double n = (sqrt(j * 8.0 + 1.0) - 1.0) / 2.0;
		int in = (int)n;

		long long sum = (in + 1) * in / 2;
		if (j == sum) {
			while (in >= 10) {
				long long copy = in;

				--in;
			}
		}
		long long index = j - sum == 0 ? in : j - sum;
		while (index >= 10) {
			long long copy = index;

		}
		printf("%I64d\n", j - sum == 0 ? in : j - sum );
	}
}